import random
from dataStruct import orderStruct as oStruct
from framework import *
from networkFramework import *
import sys


def main():
    configData = getOSConfig()
    host = configData['host']
    port = configData['port'] 
        
    if len(sys.argv) == 5:
        orders =[]
        symbol = sys.argv[1]
        price = float(sys.argv[2])
        side = int(sys.argv[3])
        size = int(sys.argv[4])
        order =(9999, symbol, side, size, price)
        orders.append(order)
    else:
        orders = makeOrders(configData['user'], configData['min'], configData['max'], configData['count'], configData['symbol'])
    
    orderObj = oStruct()
    buffSize = orderObj.getBuffSize()
    sUDPConn = senderUDPConn(host ,port)
    
    for order in orders:    
        orderObj.bufferValues(order)
        sUDPConn.sendData(orderObj.buffer.raw)
        blah = orderObj.getValues()
        print blah
          
    sUDPConn.close()

if __name__ == "__main__":
    main()